package com.yiqi.zhiyuan.feature.order.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.entity.bo.PageData;
import com.yiqi.zhiyuan.entity.vo.OrderVO;
import com.yiqi.zhiyuan.feature.order.contract.OrderContract;
import com.yiqi.zhiyuan.feature.order.dependencies.order.DaggerOrderModelComponent;
import com.yiqi.zhiyuan.framework.api.ApiLib;
import com.yiqi.zhiyuan.framework.api.OrderApi;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @ProjectName: ZhiYuan
 * @Description: 注册model
 * @Author: lijuwen
 * @CreateDate: 2019/3/13 13:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/13 13:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class OrderModel implements OrderContract.Model {
    @Inject
    OrderApi api;

    public OrderModel() {
        DaggerOrderModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<PageData<OrderVO>> doSelectOrderList(int type, int pageIndex) {
        return api.getOrderList(type,pageIndex).compose(RxDataProcessFactory.<PageData<OrderVO>>dataPrepAndIoToMainTransformer());
    }
}

